package com.app.utils;

import com.alibaba.fastjson.JSONObject;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;


import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.client.RestTemplate;

@Component
public class TaskUtil {

    // 十点执行代码
    @Scheduled(cron = "0 21 13 ? * *")
    public void autoTest(){
        System.out.println("定时任务执行了");
        RestTemplate client = new RestTemplate();
        JSONObject data = new JSONObject();
        data.put("loginName","20020210115");
        data.put("password","123123");
        ResponseEntity<String> stringResponseEntity = client.postForEntity("http://120.24.211.119:8081/practice/user/login",data,String.class);
        System.out.println(stringResponseEntity.toString());
    }
//    @Scheduled(cron = "0/3 * * * * ?")
//    public void autoTest01(){
//        System.err.println("定时任务执行了嘎嘎嘎嘎，下一次3秒后");
//    }
}
